<%--
  Created by IntelliJ IDEA.
  User: 86181
  Date: 2022/11/21
  Time: 18:37
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>登记生产派工单</title>
</head>
<body>
            <div class="row">
                <div class="col-md-offset-10"><button onclick="outbtn()" class="btn btn-primary">返回</button></div>
            </div>
            <br>
            <div align="center" style="width:1200px;height:1000px;border:1px black solid">
                <div class="row">
                    <div><h2><strong>生产派工单</strong></h2></div>
                    <input type="hidden" id="produktonid">
                </div>
                <br>
                <div class="row">
                    <div class="col-md-6">
                        <table>
                            <tr>
                                <td>派工单编号:</td>
                                <td><input type="text" readonly id="dispatchmanufactureId" name="manufactureId"  style="outline: none;border: none;background-color:white;border-radius:20px;height:35px"></td>
                            </tr>
                            <tr>
                                <td>产品编号:</td>
                                <td><input type="text" id="dispatchproductId" name="productId" readonly  style="outline: none;border: none;background-color:white;border-radius:20px;height:35px"></td>
                            </tr>
                            <tr>
                                <td>描述:</td>
                                <td><input type="text" readonly id="dispatchproductDescribe" name="productDescribe"  style="outline: none;border: none;background-color:white;border-radius:20px;height:35px"></td>
                            </tr>
                        </table>
                    </div>
                    <div class="col-md-6">
                        <table>
                            <tr>
                                <td>出库单编号:</td>
                                <td><input type="text" id="dispatch" name="" readonly  style="outline: none;border: none;border-radius:20px;height:35px"></td>
                            </tr>
                            <tr>
                                <td>产品名称:</td>
                                <td><input type="text" id="dispatchproductName" name="productName" readonly  style="outline: none;border: none;background-color:white;border-radius:20px;height:35px"></td>
                            </tr>
                            <tr>
                                <td>数量:</td>
                                <td><input type="text" id="dispatchamount" name="amount" readonly  style="outline: none;border: none;background-color:white;border-radius:20px;height:35px"></td>
                            </tr>
                        </table>
                    </div>
                </div>
                <br>
                <div  style="height:25%">
                  <div class="row">
                    <div class="col-md-offset-10"><button class="btn btn-default" onclick="jiazai()"><span class="glyphicon glyphicon-refresh"></span></button></div>
                   </div>
                    <table id="produktionsregistrierungDispatchtab">

                    </table>
                </div>
                <br>
                <div class="row">
                    <div class="col-md-6">
                        <table>
                            <tr>
                                <td>设计工时总成本:</td>
                                <td><input type="text" name="labourCostPriceSum" id="dispatchlabourCostPriceSum" readonly style="outline: none;border: none;background-color:white;border-radius:20px;height:35px"></td>
                            </tr>
                            <tr>
                                <td>实际工时总成本:</td>
                                <td><input type="text" id="dispatchrealLabourCostPriceSum" name="realLabourCostPriceSum" readonly style="outline: none;border: none;background-color:white;border-radius:20px;height:35px"></td>
                            </tr>
                            <tr>
                                <td>登记人:</td>
                                <td><input type="text" id="dispatchregister" name="register" readonly style="outline: none;border: none;background-color:white;border-radius:20px;height:35px"></td>
                            </tr>
                            <tr>
                                <td>复核人:</td>
                                <td><input type="text" id="dispatchchecker" name="checker" readonly style="outline: none;border: none;background-color:white;border-radius:20px;height:35px"></td>
                            </tr>
                        </table>
                    </div>
                    <div class="col-md-6">
                        <table>
                            <tr>
                                <td>设计物料总成本:</td>
                                <td><input type="text" id="dispatchmoduleCostPriceSum" name="moduleCostPriceSum" readonly style="outline: none;border: none;background-color:white;border-radius:20px;height:35px"></td>
                            </tr>
                            <tr>
                                <td>实际物料总成本:</td>
                                <td><input type="text" id="dispatchrealModuleCostPriceSum" name="realModuleCostPriceSum" readonly style="outline: none;border: none;background-color:white;border-radius:20px;height:35px"></td>
                            </tr>
                            <tr>
                                <td>登记时间:</td>
                                <td><input type="text" id="dispatchregisterTime" name="registerTime" readonly style="outline: none;border: none;background-color:white;border-radius:20px;height:35px"></td>
                            </tr>
                            <tr>
                                <td>复核时间:</td>
                                <td><input type="text" id="dispatchcheckTime" name="checkTime" readonly style="outline: none;border: none;background-color:white;border-radius:20px;height:35px"></td>
                            </tr>
                        </table>
                    </div>
                </div>
                <br>
            <div>
                <div class="form-group">
                    <label for="dispatch-text"  class="control-label">配置要求:</label>
                    <textarea class="form-control" readonly name="remark" id="dispatch-text" style="width:800px;height:200px;background-color:gainsboro;"></textarea>
                </div>
            </div>
            </div>
            <!--登记模态框-->
            <div class="modal fade"  tabindex="-1" role="dialog" aria-labelledby="gridSystemModalLabel" id="produktionsregistrierungDispatchmodal">
                <div class="modal-dialog modal-lg">
                    <div class="modal-content" id="produktionsregistrierungDispatchmodalson">

                    </div>
                </div>
            </div>


            <!--交接模态框-->
            <div class="modal fade"  tabindex="-1" role="dialog" aria-labelledby="gridSystemModalLabel" id="handoverregistrationmodal">
                <div class="modal-dialog modal-lg">
                    <div class="modal-content" id="handoverregistrationmodalson">

                    </div>
                </div>
            </div>
            <script>
                //加载数据
                $(function () {
                    //加载表格数据
                    $("#produktionsregistrierungDispatchtab").bootstrapTable({
                        sidePagination:"server", //分页方式：client客户端分页，server服务端分页（*）
                        showColumns: true,//是否显示所有的列（选择显示的列）
                        minimumCountColumns: 2,//最少允许的列数
                        showToggle: true,//是否显示详细视图和列表视图的切换按钮
                        cardView: false,//是否显示详细视图
                        detailView: false,//是否显示父子表,
                        columns:[
                            {
                                field:"",
                                title:"序号",
                                formatter:function (value,row,index) {
                                    return Number(index)+1
                                }
                            },
                            {
                                field:"procedureName",
                                title:"工序名称",
                            },
                            {
                                field:"labourHourAmount",
                                title:"设计工时数",
                            },
                            {
                                field:"realLabourHourAmount",
                                title:"实际工时数",
                            }, {
                                field:"subtotal",
                                title:"设计工时成本(元)",
                            },
                            {
                                field:"realSubtotal",
                                title:"实际工时成本",
                            },
                            {
                                field:"moduleSubtotal",
                                title:"设计物料成本(元)",
                            },
                            {
                                field:"realModuleSubtotal",
                                title:"实际物料成本",
                            }, {
                                field:"procedureFinishTag",
                                title:"工序登记",
                                formatter:function (value,row,index) {
                                    if(row.procedureFinishTag=="G004-0"){
                                        return "<strong><a style='color:deepskyblue' onclick='produktionsregistrierungDispatchck("+row.id+","+row.costPrice+","+(Number(index)+1)+",this)'>登记</a></strong>"
                                    }
                                    if(row.procedureFinishTag=="G004-1"){
                                        return "<strong>等待审核</strong>"
                                    }
                                    if(row.procedureFinishTag=="G004-2"){
                                        return "<strong><a style='color:deepskyblue' onclick='produktionsregistrierungDispatchck("+row.id+","+row.costPrice+","+(Number(index)+1)+",this)'>登记</a></strong>"
                                    }
                                    if(row.procedureFinishTag=="G004-3"){
                                        return "<a>完成</a>"
                                    }
                                }
                            },
                            {
                                field:"procedureTransferTag",
                                title:"工序交接",
                                formatter:function (value,row,index) {
                                    if(row.procedureFinishTag=="G004-3" && row.procedureTransferTag=="G005-0"){
                                        return "<strong><a style='color:deepskyblue' onclick='handoverregistrationbtn("+row.id+")'>交接登记</a></strong>"
                                    }
                                    if(row.procedureTransferTag=="G005-0"){
                                        return "<a></a>"
                                    }
                                    if(row.procedureTransferTag=="G005-1"){
                                        return "<a>等待审核</a>"
                                    }
                                    if(row.procedureTransferTag=="G005-2"){
                                        return "<a>完成</a>"
                                    }
                                }
                            },
                        ],
                    })
                    alo()
                })
                function alo() {
                    //获取id
                    var manufactureId='${param.manufactureId}'
                    //根据当前id查询
                    $.post("queryByMmanufacturebymanufactureId.action",{"manufactureId":manufactureId},function (data) {
                        //赋值
                        //id
                        $("#produktonid").val(data.id)
                        //派工单编号
                        $("#dispatchmanufactureId").val(data.manufactureId)
                        //产品编号
                        $("#dispatchproductId").val(data.productId)
                        //描述
                        $("#dispatchproductDescribe").val(data.productDescribe)
                        //产品名称
                        $("#dispatchproductName").val(data.productName)
                        //数量
                        $("#dispatchamount").val(data.amount)
                        //设计工时总成本
                        $("#dispatchlabourCostPriceSum").val(data.labourCostPriceSum)
                        //实际工时总成本
                        $("#dispatchrealLabourCostPriceSum").val(data.realLabourCostPriceSum)
                        //登记人
                        $("#dispatchregister").val(data.register)
                        //复核人
                        $("#dispatchchecker").val(data.checker)
                        //设计物料总成本
                        $("#dispatchmoduleCostPriceSum").val(data.moduleCostPriceSum)
                        //实际物料总成本
                        $("#dispatchrealModuleCostPriceSum").val(data.realModuleCostPriceSum)
                        //登记时间
                        $("#dispatchregisterTime").val(data.registerTime)
                        //复核时间
                        $("#dispatchcheckTime").val(data.checkTime)
                        //配置需求
                        $("#dispatch-text").val(data.remark)
                        //加载表格数据
                        //获取表格数据
                        var mprocedures=data.procedures;
                        var arr=[];
                        for (var i=0;i<mprocedures.length;i++){
                            arr.push(mprocedures[i])
                        }
                        //赋值
                        $("#produktionsregistrierungDispatchtab").bootstrapTable("load",arr)
                    },"json")
                }
                //登记
                function produktionsregistrierungDispatchck(id,costPrice,index1,vals) {
                    var  names=$(vals).parent().parent().parent().parent().find("tr").eq(0).find("td").eq(9).find("a").eq(0).text()
                    if(names!="完成" && index1!=1){
                        alert("上一次工序未完成")
                        return
                    }
                    //加载模态框
                    $("#produktionsregistrierungDispatchmodalson").load("produktionsregistrierungDispatchmodal.jsp",{"id":id,"dispatchmanufactureId":$("#dispatchmanufactureId").val(),"produktonid":$("#produktonid").val(),"costPrice":costPrice,"index1":index1})
                    //打开模态框
                    $("#produktionsregistrierungDispatchmodal").modal("show")
                }
                /*  onLoadSuccess:function () {
                    alert("134")
                   //获取表格数据
                     var arr=$("#produktionsregistrierungDispatchtab").bootstrapTable("getData")
                     //实际工时
                     var i;
                     var i1;
                     alert(arr.length)
                     $(arr).each(function (value,item) {
                         i+=Number(item.realSubtotal)
                         alert(item.realSubtotal)
                         i1+=Number(item.realModuleSubtotal)
                     })
                     //实际工时总成本
                     $("#dispatchrealLabourCostPriceSum").val(i)
                     $("#dispatchrealModuleCostPriceSum").val(i1)
                },*/
                function jiazai() {
                    alo()
                }
                //退出
                function outbtn() {
                    $("#tab1").addTabs("生产登记", "", "produktionsregistrierung.jsp", true);
                    $("#tab1").closeTabs("登记生产派工单")
                }
                //交接登记
                function handoverregistrationbtn(id) {
                    //加载模态框
                    $("#handoverregistrationmodalson").load("handoverregistrationmodal.jsp",{"id":id,"amount": $("#dispatchamount").val()})
                    //显示模态框
                    $("#handoverregistrationmodal").modal("show")
                }
            </script>
</body>
</html>
